This invention is in the technical field of image processing by means of a computer and relates in particular to methods and apparatus for measuring the position and orientation of a target object with a contour containing straight lines and inspecting whether there is a defect in the contour.
When the position and orientation of an object are observed or defects on its contour are being inspected on a variable-density image, there are situations in which it becomes desirable to extract straight-line portions from the contour of the target object. Conventional methods of extracting the contour of a target object include those by binary representation of the image, those based on the magnitude of the density gradient and those using an expanded or contracted image.
By a binary representation method, an image is divided into areas with white and black pixels and a contour line is formed by the pixels located at their boundary. By a method depending on the density gradient, the density gradient at each pixel is calculated and a contour line is formed by those of the pixels at which the density gradient exceeds a specified threshold value. By a method using an expanded or contracted image, an expanded image and a contracted image are formed by expanding the contracting the bright area of the original image and a contour line is extracted by producing a differential image therefrom.
By any of these methods, what is extracted is the contour line as a whole, and none of them can be used to extract only straight-line portions of the contour. In order to extract a straight-line portion of the contour line, it may be attempted to evaluate the connection pattern of the pixels forming the contour line and to identify the portions which may each be considered to represent a straight line, for example, by considering the pixels on the contour line sequentially to examine whether they are connected in a same direction. If it is attempted to improve the resolution of connection direction, however, an average of directions of connection of several pixels must be considered and hence very small defects which interrupt the connection will have to be ignored. If the contour lines are extracted so as to have a finite width, furthermore, it is difficult enough to establish an algorithm for extracting a straight line.
By any of these prior art methods, furthermore, the characteristics of a contour line (such as its width and position, as well as the sizes of protrusions and indentations thereon) will change, depending on the conditions of the image (such as the difference in density between the background and the target object and the uniformity in brightness). It is therefore difficult to dependably extract a straight-line portion of a contour line by any of these methods relying on evaluation of the connection pattern of pixels.